import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Dashboard from '../components/Dashboard.vue'
import ProblemDetail from '../components/ProblemDetail.vue'
import mypage from '../components/mypage.vue'
import commit from '../components/Commit.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', name: 'login', component: Login },
  { path: '/dashboard', name: 'dashboard', component: Dashboard },
  { path: '/problem/:id', name: 'problem', component: ProblemDetail },
  { path: '/mypage', name: 'mypage', component: mypage },
  { path: '/commit', name: 'commit', component: commit }


]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// Navigation guard to check authentication
// router.beforeEach((to, from, next) => {
//     const isAuthenticated = localStorage.getItem('isAuthenticated')
//   if (to.name !== 'login' && !isAuthenticated) next({ name: 'login' })
//    else next()
//  })

export default router